package Package;

import java.util.Stack;

public class MinStack {

        Stack<Integer> stack;
        Stack<Integer> MinStack;
        public MinStack() {
            stack = new Stack<Integer>();
            MinStack = new Stack<Integer>();
        }

        public void push(int val) {
            stack.push(val);
            if(MinStack.isEmpty() || MinStack.peek() >= val){
                MinStack.push(val);
            }
        }

        public void pop() {
            if(stack.peek().equals(MinStack.peek())){
                MinStack.pop();
            }
            stack.pop();
        }

        public int top() {
            return stack.peek();
        }

        public int getMin() {
            return MinStack.peek();
        }
    }

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack obj = new MinStack();
 * obj.push(val);
 * obj.pop();
 * int param_3 = obj.top();
 * int param_4 = obj.getMin();
 */

